import request from '@/utils/request'

// 查询商品分类列表
export function listShangpinfenlei(query) {
  return request({
    url: '/shangpinfenlei/shangpinfenlei/list',
    method: 'get',
    params: query
  })
}

// 查询商品分类详细
export function getShangpinfenlei(categoryId) {
  return request({
    url: '/shangpinfenlei/shangpinfenlei/' + categoryId,
    method: 'get'
  })
}

// 新增商品分类
export function addShangpinfenlei(data) {
  return request({
    url: '/shangpinfenlei/shangpinfenlei',
    method: 'post',
    data: data
  })
}

// 修改商品分类
export function updateShangpinfenlei(data) {
  return request({
    url: '/shangpinfenlei/shangpinfenlei',
    method: 'put',
    data: data
  })
}

// 删除商品分类
export function delShangpinfenlei(categoryId) {
  return request({
    url: '/shangpinfenlei/shangpinfenlei/' + categoryId,
    method: 'delete'
  })
}

// 获取父类别列表
export function getParentCategories() {
  return request({
    url: '/shangpinfenlei/shangpinfenlei/parents',
    method: 'get'
  })
}

// 根据父类别ID获取子类别列表
export function getChildCategories(parentCategoryId) {
  return request({
    url: '/shangpinfenlei/shangpinfenlei/children/' + parentCategoryId,
    method: 'get'
  })
}